home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / gencodec / safe memory / mem.doc < prev    next >
Text File  |  1999-01-01  |  4KB  |  104 lines

  1.  
  2.                   MEM: A memory management safety net.
  3.  
  4.                              written by
  5.  
  6.                            ---------------
  7.                            Simon    Bullen
  8.                            10 Hogan Street
  9.                            Sunbury    3429
  10.                            Australia
  11.                            ---------------
  12.  
  13.   In this archive, there should be the following files:
  14.  
  15.           mem.doc          3594 bytes
  16.           mem.c            6801 bytes
  17.           mem.h             523 bytes
  18.  
  19.  
  20.     Ever had the problem of a program you're trying to debug swallowing
  21.   24 bytes somewhere, and not knowing where? Or perhaps you're playing
  22.   around with one of the more complex memory structures, and it gurus
  23.   a lot due to incorrect memory frees? Painful to debug, aren't they?
  24.  
  25.     Well, no longer!! With these two teeny files, your programs will crash
  26.   from memory mismanagement never again!
  27.  
  28.     mem.c provides a safety net around all your calls to AllocMem and
  29.   FreeMem, recording what you've allocated, and where you allocated (ie
  30.   where in the source-code). Then, when you do something wrong (like try to
  31.   free something you never allocated), it simply displays a nice little
  32.   debug message like this:
  33.  
  34. hello.c 44: Incorrect free size. (64 instead of 2300)
  35.  
  36.   or this:
  37.  
  38. hello.c 45: Free twice (?). ($34, 2478756)
  39.  
  40.     There must be very few Amiga programmers out there who haven't
  41.   had the "Free Twice" guru!
  42.  
  43.  
  44.     mem.c also provides a mechanism to find out just what you haven't
  45.   gotten around to freeing yet (you've been -meaning- to for ages...):
  46.  
  47.  
  48. hello.c 76: Memory List
  49.  
  50.     Address      Size        File           Line
  51.     -------      ----        ----           ----
  52.     $123450      24          hello.c        42
  53.     $200000      4500        there.c        97
  54.  
  55.  
  56.   Useful, eh? But that's not all!! Gone are the days when you have to
  57.   reboot your computer every time your rogue program eats up all your
  58.   precious memory; A simple call will free everything you allocated!
  59.  
  60.     Ok, enough of the advertisement; here's how to do it:
  61.  
  62.   Simply #include "mem.h" (make sure you put that AFTER #include
  63.   "proto/exec.h" !!!!!!). Link with mem.o, and place calls to
  64.   ShowMemList() and ClearMemList() where-ever you feel appropriate. (At the
  65.   end of main() is the most obvious place, though the more industrious
  66.   could put the calls in break & exit traps.)
  67.  
  68.     To find out how it works, read the extensive documentation in mem.c.
  69.  
  70.  
  71.  
  72.  
  73.                   MEM: A memory management safety net.
  74.  
  75.                              written by
  76.  
  77.                            ---------------
  78.                            Simon    Bullen
  79.                            10 Hogan Street
  80.                            Sunbury    3429
  81.                            Australia
  82.                            ---------------
  83.  
  84.                       ----------------------------
  85.                       s914373@minyos.xx.rmit.OZ.AU
  86.                       ----------------------------
  87.  
  88.  
  89.                 You are free to do whatever you like with
  90.                 this software, so long as you give credit
  91.                 where credit is due.
  92.  
  93.                 If you find it useful (like it saves you
  94.                 3 days of debugging time), send whatever
  95.                 you feel appropriate  ($10 would be most
  96.                 welcome!).
  97.  
  98.                 I would be very  interested  to here any
  99.                 comments,  suggestions,  and  flames you
  100.                 may have.  (Please,  dont  take  it upon
  101.                 yourself  to   point  out  my   spelling
  102.                 errors!).
  103.  
  104.